//
//  LoginTextFiled.m
//  ZHIDOU
//
//  Created by 向礼 on 2018/12/25.
//  Copyright © 2018 向礼. All rights reserved.
//

#import "LoginTextFiled.h"
@interface LoginTextFiled()
@property (weak, nonatomic) IBOutlet UIView *lineView;
@property (weak, nonatomic) IBOutlet UIImageView *leftImageView;
@property (weak, nonatomic) IBOutlet UITextField *PhoneTextField;
@property (weak, nonatomic) IBOutlet UIButton *clearBtn;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *rightTextFiled;

@end

@implementation LoginTextFiled
- (instancetype)initWithFrame:(CGRect)frame {
    if (self = [super initWithFrame:frame]) {
        self = [[NSBundle mainBundle] loadNibNamed:@"LoginTextFiled" owner:self options:nil].firstObject;
        self.frame = frame;
        self.autoresizingMask = NO; // 否则会根据父视图大小变化
    }
    return self;
}

- (void)awakeFromNib {
    [super awakeFromNib];
   
}

-(void)setFiledType:(TextFiledType)filedType{
    _filedType = filedType;
    switch (_filedType) {
        case phoneType:{
            UIButton *clearButton = [_PhoneTextField valueForKey:@"_clearButton"];
            [clearButton setImage:[UIImage imageNamed:@"login_fork"]forState:UIControlStateNormal];
            _PhoneTextField.clearButtonMode = UITextFieldViewModeWhileEditing;
            _rightTextFiled.constant = 0;
            _clearBtn.hidden = YES;
            break;}
        case passWordType:{
            _rightTextFiled.constant = 50;
            _clearBtn.hidden = NO;
            break;
        }
    }
}


-(void)setPlaceStr:(NSString *)PlaceStr{
    _PlaceStr = PlaceStr;
    if (_PlaceStr) {
      _PhoneTextField.placeholder =_PlaceStr;
    }
}

-(void)setLeftImage:(NSString *)leftImage{
    _leftImage = leftImage;
    if (_leftImage) {
        _leftImageView.image = [UIImage imageNamed:_leftImage];
    }
}

@end
